# This file is part of Sonedyan.
#
# Sonedyan is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation;
# either version 3 of the License, or (at your option) any
# later version.
#
# Sonedyan is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
# PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public.
# If not, see <http://www.gnu.org/licenses/>.
#
# Copyright (C) 2009-2012 Jimmy Dubuisson <jimmy.dubuisson@gmail.com>

#
# usage: python make-global-statistics.py
#

# count the total number of 1grams
files = ["0.csv", "1.csv", "2.csv", "3.csv", "4.csv", "5.csv", "6.csv", "7.csv", "8.csv", "9.csv"]

totalGramsCount = 0
yearlyGramsCount = {}

for f in files:
	fd = open(f, "r")
	line = fd.readline().strip()

	while line:
		ngram, year, matchCount, pageCount, volumeCount = line.split()
		totalGramsCount += int(matchCount)
		
		if yearlyGramsCount.has_key(year):
			yearlyGramsCount[year] += int(matchCount)
		else:
			yearlyGramsCount[year] = int(matchCount)

		line = fd.readline().strip()		

	fd.close()	

print "# Total number: " + str(totalGramsCount) + "\n"

for k in sorted(yearlyGramsCount.iterkeys()):
	print k + ":" + str(yearlyGramsCount[k])
